<body>
    <script>
        var obj= {
            name:'三三',
            age:20,
            sex:'女',
        }
        var obj1 = obj;
    //   浅拷贝
        // obj.name = 'root'
        var obj2 ={}




     // 深拷贝
        // obj2.name = obj.name
        // obj2.age = obj.age
        // obj2.sex = obj.sex

        // obj2.name = '李四'
        for(var i in obj){
            // console.log(i)
            // console.log(obj[i])

            obj2[i] = obj[i]
        }
        obj2.name = '李四'

        console.log(obj)
        console.log(obj2)
        



    //    for-in 语法
          var obj3 ={};
        for(var i in obj){
             obj3[i]= obj2[i]
        }
        obj3.age = 100;
        console.log(obj3)

        </script>
</body>